package com.yeung.springcloud.controller;

import com.yeung.springcloud.entities.Dept;
import com.yeung.springcloud.entities.com.yeung.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//消费端 只管消费, 所以不存在service 这种对象
//由于使用了Feign负载均衡, 通过Feign来获取实际的服务接口
@RestController
public class DeptController_Consumer {
    @Autowired
    private DeptClientService service;

    //使用http 进行远端调用
    @RequestMapping(value = "/consumer/dept/add")
    public boolean add(Dept dept) {
        return service.add(dept);
    }

    @RequestMapping(value = "/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id) {
        return service.get(id);
    }

    @RequestMapping(value = "/consumer/dept/list")
    public List<Dept> list() {
        return service.list();
    }

}
